/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.carpark.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Adrian Farmadin
 */
@Entity
public class BusinessTrip implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @ManyToOne
    @NotNull
    private Employee employee;
    
    @ManyToOne
    @NotNull
    private Vehicle vehicle;
    
    @Column(name = "Number_Of_Driven_Kms")
    @Min(0)
    private int numberOfDrivenKms;
    
    @Temporal(TemporalType.DATE)
    @Column(name = "Date_Of_Trip")
    @NotNull
    private Date dateOfTrip;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public Vehicle getVehicle() {
        return vehicle;
    }

    public void setVehicle(Vehicle vehicle) {
        this.vehicle = vehicle;
    }

    public int getNumberOfDrivenKms() {
        return numberOfDrivenKms;
    }

    public void setNumberOfDrivenKms(int numberOfDrivenKms) {
        this.numberOfDrivenKms = numberOfDrivenKms;
    }

    public Date getDateOfTrip() {
        return dateOfTrip;
    }

    public void setDateOfTrip(Date dateOfTrip) {
        this.dateOfTrip = dateOfTrip;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BusinessTrip)) {
            return false;
        }
        BusinessTrip other = (BusinessTrip) object;
        if ( (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "BusinessTrip{" + "id=" + id + ", employee=" + employee + ", vehicle=" + vehicle + ", numberOfDrivenKms=" + numberOfDrivenKms + ", dateOfTrip=" + dateOfTrip + '}';
    }

    
}
